import sys
from PyQt5.QtWidgets import QApplication, QWidget,QPushButton,QFormLayout,QLineEdit
from PyQt5.QtCore import pyqtSlot
# edit_name = QLineEdit =None
# edit_age = QLineEdit =None
# edit_phone = QLineEdit =None

def on_submit():
    print("提交")
    print("姓名：",edit_name.text())
    print("年龄：",edit_age.text())
    print("手机号：",edit_phone.text())
#------------------------------------------------------
def init_widget(w:QWidget):
    # 设置窗口标题
    w.setWindowTitle("布局")
    w.resize(640, 480)
    
    #创建布局
    layout = QFormLayout(w)
    
    global edit_name,edit_age,edit_phone
    
    edit_name = QLineEdit()
    edit_age = QLineEdit()
    edit_phone = QLineEdit()
    layout.addRow("姓名：",edit_name)
    layout.addRow("年龄：",edit_age)
    layout.addRow("手机号：",edit_phone)
    btn_submit = QPushButton("提交")
    btn_submit.clicked.connect(on_submit)
    layout.addRow(btn_submit)
    
if __name__ == "__main__":
    # 1.创建应用程序
    app = QApplication(sys.argv)
    # 2.创建窗口
    w = QWidget()
    init_widget(w)
    # 3显示窗口
    w.show()
    # 4.等待窗口停止运行
    sys.exit(app.exec_())
